export default function collateRouter (routerObj) {
  let newRouter = { ...routerObj }
  if (newRouter['component'] == 'Layout') {
    newRouter['component'] = (resolve) => require(['@/layout'], resolve)
  } else {
    newRouter['component'] = (resolve) => require([`@/views/${newRouter['component']}`], resolve)
  }
  if (newRouter['children'] && newRouter['children'].length > 0) {
    newRouter['children'].forEach(item => {
      collateRouter(item)
    });
  }
  return newRouter
}